import { defineStore } from "pinia";
import { WeatherPrediction } from "@/types/prediction";

const usePredictionStore = defineStore("prediction", {
    state: () => ({
        fileDetails: new Map<string, WeatherPrediction[]>(),
    }),
    getters: {
        // 获取文件详情
        getFileDetail: (state) => (filePath: string) => {
            return state.fileDetails.get(filePath);
        },
    },
    actions: {
        // 新增文件详情
        addFileDetail(filePath: string, fileDetail: WeatherPrediction[]) {
            this.fileDetails.set(filePath, fileDetail);
        },
        // 检查文件详情是否存在
        checkDetailExisted(filePath: string) {
            return this.fileDetails.has(filePath);
        },
    },
});

export default usePredictionStore;
